package cuit.blog.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import jakarta.persistence.*;

@Entity
@Table(name = "t_articletype")
public class Articletype extends BaseEntity {

    @Column(name = "type")
    private String type;
    @OneToMany(mappedBy = "articletype", cascade = {CascadeType.ALL}, orphanRemoval = true)
    private List<Article> Articles = new ArrayList<Article>();
    public Articletype() {
    }
    public List<Article> getArticles() {
        return Articles;
    }
 // getter 和 setter 方法
    public void setArticles(List<Article> Articles) {
        if (Articles == null || Articles.isEmpty()) {
            this.Articles = new ArrayList<>();
        } else if (this.Articles == null || Articles.size() != 0) {
            this.Articles = new ArrayList<>();
            this.Articles.addAll(Articles);
        } else {
            this.Articles.clear();
            this.Articles.addAll(Articles);
        }
    }
    @Override
	public long getId() {
		// TODO Auto-generated method stub
		return super.getId();
	}

	@Override
	public void setId(long id) {
		// TODO Auto-generated method stub
		super.setId(id);
	}

	public void setType(String type) {
	this.type = type;
    }

    public String getType() {
	return type;
    }

    @Override
	public Date getCreateTime() {
		// TODO Auto-generated method stub
		return super.getCreateTime();
	}
	@Override
	public void setCreateTime(Date createTime) {
		// TODO Auto-generated method stub
		super.setCreateTime(createTime);
	}
	public String toString() {
	return super.getId() + "," + type + "," + super.getCreateTime() + "," + super.getUpdateTime();
    }
}
